<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateOrderTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('order', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('user_name',50)->default('');
            $table->integer('product_id')->default(0);
            $table->string('product_name',100)->default('')->comment('产品名称');
            $table->string('product_capacity',100)->default('')->comment('产品T数');
            $table->string('product_token',100)->default('')->comment('产品token');
            $table->string('product_hostrate',100)->default('')->comment('产品hostrate');
            $table->string('pay_type',50)->default('')->comment('支付方式usdt,alipay,wechat,bank');
            $table->string('pay_account',200)->default('')->comment('支付账号（交易hash）');
            $table->string('pay_name',50)->default('')->comment('支付用户（交易钱包）');
            $table->tinyInteger('status')->default(0)->comment('状态,0未审核,1审核通过,2驳回');
            $table->decimal('unit_price',10,2)->default(0)->comment('单价');
            $table->decimal('all_price',10,2)->default(0)->comment('总金额');
            $table->integer('all_capacity')->default(0)->comment('容量');
            $table->integer('all_cny')->default(0)->comment('总金额，人名币');
            $table->integer('buy_num')->default(0)->comment('购买数量');
            $table->timestamp('add_time')->default(DB::raw('CURRENT_TIMESTAMP'));
            $table->text('pic')->nullable()->comment('图片地址');
            $table->text('note')->nullable()->comment('备注');
            $table->timestamp('check_time')->nullable()->comment('审核时间');
            $table->string('reject_reason','200')->nullable()->comment('驳回理由');
            $table->decimal('rate','20',4)->default(0)->comment('当时汇率');
            $table->dateTime('updated_at')->nullable();
            $table->engine = 'InnoDB';
            $table->charset = 'utf8';
            $table->collation = 'utf8_unicode_ci';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('order');
    }
}
